# -*- coding: utf-8 -*-
"""
__author__ = 'bingo'
__date__ = '2019/3/15'
# code is far away from bugs with the god animal protecting
    I love animals. They taste delicious.
              ┏┓      ┏┓
            ┏┛┻━━━┛┻┓
            ┃      ☃      ┃
            ┃  ┳┛  ┗┳  ┃
            ┃      ┻      ┃
            ┗━┓      ┏━┛
                ┃      ┗━━━┓
                ┃  神兽保佑    ┣┓
                ┃　永无BUG！   ┏┛
                ┗┓┓┏━┳┓┏┛
                  ┃┫┫  ┃┫┫
                  ┗┻┛  ┗┻┛
"""

from rest_framework import serializers
from news.models import Tag, Article, HotArticle, Comment, Banner
from user.serializers import UserSerializer


class TagSerializer(serializers.ModelSerializer):
    """
    Tag序列器
    """

    class Meta:
        model = Tag
        fields = ['id', 'name']


class ArticleSerializer(serializers.ModelSerializer):
    """
    Article序列器
    """
    author = UserSerializer()
    tag = TagSerializer()

    class Meta:
        model = Article
        fields = '__all__'


class CommentSerializer(serializers.ModelSerializer):
    """
    Comment序列器
    """
    author = UserSerializer()
    news = ArticleSerializer()

    class Meta:
        model = Comment
        fields = '__all__'


class HotArticleSerializer(serializers.ModelSerializer):
    """
    HotArticle序列器
    """
    article = ArticleSerializer()

    class Meta:
        model = HotArticle
        fields = ['article', 'priority']


class BannerSerializer(serializers.ModelSerializer):
    """
    Banner序列器
    """
    class Meta:
        model = Banner
        fields = '__all__'
